﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace PPIDesktopClient
{
    public partial class frmBase : DevComponents.DotNetBar.Office2007Form
    {
        public List<Validator> GetAllValidators()
        {
            return GetAllValidators(this);
        }
        public List<Validator> GetAllValidators(Control parent)
        {
            List<Validator> _Validators = new List<Validator>();
            foreach (Control _Control in parent.Controls)
                if (_Control is Validator)
                    _Validators.Add((Validator)_Control);
                else if (_Control.Controls.Count > 0)
                    _Validators.AddRange(GetAllValidators(_Control));
            return _Validators;
        }
        public bool ValidateAll()
        {
            bool _IsValid = true;
            foreach (Validator _Val in GetAllValidators())
            {
                _Val.Validate();
                _IsValid &= _Val.IsValid;
            }
            return _IsValid;
        }
        public frmBase()
        {
            InitializeComponent();
        }
    }
}
